﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefBadProductRecord" :model="stateBadProductRecord.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_FactoryCode_FormItem" prop="Entity.FactoryCode" :label="$t('message.autotrans._Model_BadProductRecord_factoryCode')">
            <el-input v-model="stateBadProductRecord.vmModel.Entity.FactoryCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_LineCode_FormItem" prop="Entity.LineCode" :label="$t('message.autotrans._Model_BadProductRecord_lineCode')">
            <el-input v-model="stateBadProductRecord.vmModel.Entity.LineCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_SnNumber_FormItem" prop="Entity.SnNumber" :label="$t('message.autotrans._Model_BadProductRecord_snNumber')">
            <el-input v-model="stateBadProductRecord.vmModel.Entity.SnNumber" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_StationCode_FormItem" prop="Entity.StationCode" :label="$t('message.autotrans._Model_BadProductRecord_stationCode')">
            <el-input v-model="stateBadProductRecord.vmModel.Entity.StationCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_MaterialCode_FormItem" prop="Entity.MaterialCode" :label="$t('message.autotrans._Model_BadProductRecord_materialCode')">
            <el-input v-model="stateBadProductRecord.vmModel.Entity.MaterialCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_MaterialName_FormItem" prop="Entity.MaterialName" :label="$t('message.autotrans._Model_BadProductRecord_materialName')">
            <el-input v-model="stateBadProductRecord.vmModel.Entity.MaterialName" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_MaterialVersion_FormItem" prop="Entity.MaterialVersion" :label="$t('message.autotrans._Model_BadProductRecord_materialVersion')">
            <el-input v-model="stateBadProductRecord.vmModel.Entity.MaterialVersion" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_OperationCode_FormItem" prop="Entity.OperationCode" :label="$t('message.autotrans._Model_BadProductRecord_operationCode')">
            <el-input v-model="stateBadProductRecord.vmModel.Entity.OperationCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_DefectSource_FormItem" prop="Entity.DefectSource" :label="$t('message.autotrans._Model_BadProductRecord_defectSource')">
            <el-input v-model="stateBadProductRecord.vmModel.Entity.DefectSource" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_UploadFlag_FormItem" prop="Entity.UploadFlag" :label="$t('message.autotrans._Model_BadProductRecord_UploadFlag')">
            <el-input v-model="stateBadProductRecord.vmModel.Entity.UploadFlag" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_CreateTime_FormItem" prop="Entity.CreateTime" :label="$t('message.autotrans._Model_BadProductRecord_CreateTime')">
            <el-input v-model="stateBadProductRecord.vmModel.Entity.CreateTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_UpdateTime_FormItem" prop="Entity.UpdateTime" :label="$t('message.autotrans._Model_BadProductRecord_UpdateTime')">
            <el-input v-model="stateBadProductRecord.vmModel.Entity.UpdateTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_CreateBy_FormItem" prop="Entity.CreateBy" :label="$t('message.autotrans._Model_BadProductRecord_CreateBy')">
            <el-input v-model="stateBadProductRecord.vmModel.Entity.CreateBy" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_UpdateBy_FormItem" prop="Entity.UpdateBy" :label="$t('message.autotrans._Model_BadProductRecord_UpdateBy')">
            <el-input v-model="stateBadProductRecord.vmModel.Entity.UpdateBy" disabled clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

      <div style="text-align:right;">
        <WtmButton @click="onCloseBadProductRecord"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageRecordBadProductRecordDetails;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { badproductrecordApi } from '/@/api/record/badproductrecord';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefBadProductRecord = ref();
const stateBadProductRecord = reactive({
    vmModel: {
	  Entity:{
        FactoryCode: '',
        LineCode: '',
        SnNumber: '',
        StationCode: '',
        MaterialCode: '',
        MaterialName: '',
        MaterialVersion: '',
        OperationCode: '',
        DefectSource: '',
        UploadFlag: undefined,
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
        ID:null,
      },

	},
    
});

// 取消
const onCloseBadProductRecord = () => {
    closeDialog();
};

// 提交
const onSubmitBadProductRecord = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefBadProductRecord.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            badproductrecordApi().edit(stateBadProductRecord.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
	})
};

// 页面加载时
onMounted(() => {
    
    if (ci.attrs["wtmdata"]) {
		stateBadProductRecord.vmModel.Entity.ID = ci.attrs["wtmdata"].ID;
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateBadProductRecord.vmModel.Entity.ID = useRouter().currentRoute.value.query.id as any;
	}
	badproductrecordApi().get(stateBadProductRecord.vmModel.Entity.ID ?? "").then((data: any) => other.setValue(stateBadProductRecord.vmModel, data));
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

